import request from "@/utils/request";

export default {
  // 获取车辆列表
  getCarList(searchModel) {
    return request({
      url: "/car/list",
      method: "get",
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        plateNumber: searchModel.plateNumber,
        status: searchModel.status,
      },
    });
  },

  // 添加车辆信息
  addCar(car) {
    return request({
      url: "/car/add",
      method: "post",
      data: car,
    });
  },

  getCarById(id) {
    return request({
      url: `/car/getCarById/${id}`,
      method: "get",
    });
  },

  deleteByid(id) {
    return request({
      url: `/car/delete/${id}`,
      method: "delete",
    });
  },

  updateById(car) {
    return request({
      url: `/car/update`,
      method: "put",
      data: car,
    });
  },

  saveCar(car) {
    if (car.id) {
      return this.updateById(car);
    } else {
      return this.addCar(car);
    }
  },

  getCarOptions() {
    return request({
      url: `/car/getCarSelector`,
      method: "get",
    });
  },
};
